package com.cskaoyan.session2;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Macro_Ray
 * @since 2024/5/2 上午9:59
 */
@WebServlet("/")
@MultipartConfig
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String requestURI = req.getRequestURI();
        String op = requestURI.replace(req.getContextPath() + "/user/", "");
        if ("register".equals(op)) {
            register(req, resp);
        }
    }

    private void register(HttpServletRequest req, HttpServletResponse resp) {
        // 需要做的事情便是将文件存储起来，我们的要求是存储在非应用根目录下的某个目录内
        // D：/image/----存储的位置写到配置文件中会比较好，后续更好，只需要更换配置文件里面的配置即可
        // 注册成功之后，需要做的事情是要把一个访问地址返回给客户端，客户端再次发起请求，服务器需要做的事情就是将文件相应给客户端

    }
}
